<template>
  <div class="storeReport">
    <CommonBtn label-name="MDM门店清单报告" v-if="!button || (button.event!='add()' && button.event!='edit()') " :buttons="buttons" @onButtonClick="onButtonClick">
      <span slot="conditions" v-for="(item,index) of conditions" :key="index" v-if="item.checked">{{item.label+":"+(item.type=='search'?item.proxy:item.value)}}</span>
    </CommonBtn>
    <CommonList ref="list" v-if="!button || (button.event!='add()' && button.event!='edit()')" :buttons="buttons"
                :columns="columns" :listUrl="listUrl" @tableSelect="tableSelect" :conditions="conditions"></CommonList>
    <SearchPopUp :out-btn="button"
                   :props="columns" @close="close"
                   :out-conditions="conditions"
                   @conditionChange="conditionChange"></SearchPopUp>
    <CommonExport :out-btn="button" :props="columns"
                  @close="close" :export-url="$api.API_MDMRETAILER_EXPORT" :conditions="conditions"></CommonExport>
  </div>
</template>

<script>
    import CommonList from "../../common/CommonList";
    import CommonBtn from "../../common/CommonBtn";
    import SearchPopUp from "../../common/SearchPopUp";
    import CommonExport from "../../common/CommonExport";
    export default {
        name:'storeReport',
        data(){
            return{
                buttons:[
                    this.$config.BTNS.EXPORT,
                    this.$config.BTNS.SEARCH
                ],
                columns:[
                    {
                        prop:'mdmCode',
                        label:'统一编码',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'retailName',
                        label:'门店名称',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'cooperationStatus',
                        label:'门店合作状态',
                        search:true,
                        type:'text',
                        placeholder:'终止合作/合作中'
                    },
                    {
                        prop:'businessStatus',
                        label:'营业状态',
                        search:true,
                        type:'text',
                        placeholder:'营业中/关闭'
                    },
                    {
                        prop:'province',
                        label:'省份',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'physicalCity',
                        label:'市区',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'adminCity',
                        label:'区县'
                    },
                    {
                        prop:'retailerAddress',
                        label:'详细地址'
                    },
                    {
                        prop:'customNameCN',
                        label:'客户集团',
                        search:true,
                        type:'search',
                        searchUrl:this.$api.API_SELECT_CUSTOMER_GROUP_INFO,
                        searchLabel:'客户集团',
                        searchProxy:'customNameCN',
                        searchValue:'pkid',
                        proxy:'customNameCN',
                        queryProp:'fkRetailGroup',
                        columns:[
                            {
                                prop:'customCode',
                                label:'客户集团编码',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'customNameCN',
                                label:'集团中文名称',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'customNameEN',
                                label:'集团英文名称',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'accountCode',
                                label:'预算Account',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'customTypeName',
                                label:'集团分类',
                                search:true,
                                type:'search',
                                columns:[
                                    {
                                        prop:'customTypeCode',
                                        label:'集团类型编码',
                                        search:true,
                                        type:'text'
                                    },
                                    {
                                        prop:'customTypeName',
                                        label:'集团类型名称',
                                        search:true,
                                        type:'text'
                                    },
                                    {
                                        prop:'valid',
                                        label:'是否有效',
                                        search:true,
                                        type:'checkbox'
                                    }
                                ],
                                searchUrl:this.$api.API_CUSTOMERCLASSIFY_LIST,
                                searchLabel:'客户集团分类',
                                searchProxy:'customTypeCode',
                                searchValue:'pkid',
                                queryProp:'fkCustomType'
                            },
                            {
                                prop:'isValid',
                                label:'是否有效',
                                search:true,
                                type:'checkbox'
                            }
                        ]
                    },
                    {
                        prop:'isLKAvalue',
                        label:'是否LKA',
                        search:true,
                        type:'checkbox',
                        trueLabel:'true',
                        falseLabel:'false'
                    },
                    {
                        prop:'retailTypeName',
                        label:'门店类型',
                        search:true,
                        type:'search',
                        columns:[
                            {
                                prop:'retailName',
                                label:'门店类型名称',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'retailCode',
                                label:'门店类型编码',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'sortCode',
                                label:'排序',
                                search:true,
                                type:'text'
                            },
                            {
                                prop: 'isValid',
                                label: '是否有效'
                            }
                        ],
                        searchUrl:this.$api.API_SELECT_RETAIL_TYPE_INFO,
                        searchLabel:'门店类型',
                        proxy:'retailTypeName',
                        searchProxy:'retailName',
                        queryProp:'fkRetailType',
                        searchValue:'pkid'
                    },
                    {
                        prop:'locationName',
                        label:'Location',
                        search:true,
                        type:'search',
                        columns:[
                            {
                                prop:'locationCode',
                                label:'location代码',
                                search:true,
                                type:'text'
                            },{
                                prop:'locationName',
                                label:'location名称',
                                search:true,
                                type:'text'
                            }
                        ],
                        searchUrl:this.$api.API_COMMON_LOCATION_INFO,
                        searchLabel:'Location',
                        proxy:'locationName',
                        searchProxy:'locationName',
                        queryProp:'fkLocation',
                        searchValue:'pkid'
                    },{
                        prop:'levelName',
                        label:'门店投资属性',
                        search:true,
                        type:'text'
                    },{
                        prop:'buName',
                        label:'业务单位',
                        search:true,
                        type:'search',
                        columns:[{
                            prop: 'buCode',
                            label: '业务单位代码',
                            type:'text',
                            search:true
                        },{
                            prop: 'buName',
                            label: '业务单位名称',
                            type:'text',
                            search:true
                        }],
                        searchUrl:this.$api.API_BUSETTING_LIST,
                        searchLabel:'业务单位',
                        searchProxy:'buName',
                        queryProp:'fkBu',
                        searchValue:'pkid'
                    },{
                        prop:'regionName',
                        label:'地理Region',
                        search:true,
                        type:'search',
                        columns:[
                            {
                                prop: 'buName',
                                label: 'BU',
                                type:'text'
                            },{
                                prop: 'zoneName',
                                label: '大区名称',
                                type:'text',
                                search:true
                            },{
                                prop: 'zoneCode',
                                label: '大区代码',
                                type:'text',
                                search:true
                            },{
                                prop: 'isValid',
                                label: '是否有效'
                            }
                        ],
                        searchUrl:this.$api.API_QUERYZONE,
                        searchLabel:'大区信息',
                        proxy:'regionName',
                        searchProxy:'zoneName',
                        //queryProp:'fkregion',
                        queryProp:'regionName',
                        //searchValue:'pkid'
                        searchValue:'zoneName'
                    },{
                        prop:'areaName',
                        label:'地理Area',
                        search:true,
                        type:'search',
                        columns:[
                            {
                                prop: 'buName',
                                label: 'BU',
                                type:'text'
                            },{
                                prop:'regionName',
                                label:'区域名称',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'regionCode',
                                label:'区域代码',
                                search:true,
                                type:'text'
                            },
                            {
                                prop:'zoneName',
                                label:'大区名称',
                                search:true,
                                type:'search',
                                columns:[
                                    {
                                        prop: 'zoneName',
                                        label: '大区名称',
                                        type:'text',
                                        search:true
                                    },{
                                        prop: 'zoneCode',
                                        label: '大区代码',
                                        type:'text',
                                        search:true
                                    },{
                                        prop: 'isValid',
                                        label: '是否有效'
                                    }
                                ],
                                searchUrl:this.$api.API_QUERYZONE,
                                searchLabel:'大区信息',
                                proxy:'zoneName',
                                searchProxy:'zoneName',
                                queryProp:'fkZone',
                                searchValue:'pkid'
                            },
                            {
                                prop:'isValid',
                                label:'是否有效'
                            }
                        ],
                        searchUrl:this.$api.API_QUERYREGION,
                        searchLabel:'大区信息',
                        proxy:'areaName',
                        searchProxy:'regionName',
                        queryProp:'areaName',
                        searchValue:'regionName'
                    },{
                        prop:'cityTypeName',
                        label:'城市类别'
                    },{
                        prop:'supplyStatus',
                        label:'与供货方合作状态'
                    },{
                        prop:'typeName',
                        label:'供货方式'
                    },{
                        prop:'dealerRegionName',
                        label:'供货方Region'
                    },{
                        prop:'dealerAreaName',
                        label:'供货方Area'
                    },{
                        prop:'dealerSMMSCode',
                        label:'经销商编码',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'dealerSMMSName',
                        label:'经销商名称'
                    },
                    {
                        prop:'zcSMMSCode',
                        label:'总仓编码',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'zcSMMSName',
                        label:'总仓名称'
                    },
                    {
                        prop:'subDealerSMMSCode',
                        label:'分销商编码',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'subDealerSMMSName',
                        label:'分销商名称'
                    },
                    {
                        prop:'isFee',
                        label:'是否申请费用',
                        search:true,
                        type:'checkbox',
                        trueLabel:'是',
                        falseLabel:'否'
                    },
                    {
                        prop:'tpwfCode',
                        label:'TPCode',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'jdesCode',
                        label:'JDESCode',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'posCode',
                        label:'PosCode',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'sfaCode',
                        label:'SFACode',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'cdccCode',
                        label:'CDCCCode',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'isSFA',
                        label:'是否SFA覆盖',
                        search:true,
                        type:'checkbox'
                    },
                    {
                        prop:'dealerRepCode',
                        label:'客户负责人ID',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'dealerRepName',
                        label:'客户负责人'
                    },
                    {
                        prop:'jnjRepCode',
                        label:'强生负责人ID',
                        search:true,
                        type:'text'
                    },
                    {
                        prop:'jnjRep',
                        label:'强生负责人',
                        // search:true,
                        // type:'search',
                        //   columns:[
                        //     {
                        //         prop:'repCode',
                        //         label:'负责人账号',
                        //         search:true,
                        //         type:'text'
                        //     },{
                        //         prop:'repName',
                        //         label:'负责人姓名',
                        //         search:true,
                        //         type:'text'
                        //     }
                        // ],
                        // searchUrl:this.$api.API_GETTPINFO_LIST,
                        // searchLabel:'强生负责人',
                        // proxy:'repName',
                        // searchProxy:'repName',
                        // queryProp:'jnjRep',
                        // searchValue:'repName'
                    },
                    {
                        prop:'sfaRepCode',
                        label:'SFA销售主管ID',
                        search:true,
                        type:'text'
                        
                    },
                    {
                        prop:'sfaRepName',
                        label:'SFA销售主管'
                    },
                    {
                        prop:'ksr',
                        label:'KSR/DSR'
                    },
                    {
                        prop:'asm',
                        label:'ASM'
                    },
                    {
                        prop:'rsm',
                        label:'RSM'
                    },
                    {
                        prop:'retailerStatus',
                        label:'状态'
                    },
                    {
                        prop:'createTime',
                        label:'创建时间'
                    },
                    {
                        prop:'modifyTime',
                        label:'最后修改时间'
                    }
                ],
                listUrl:this.$api.API_SELECT_RETAILER_LISTDTO,
                button:{},
                conditions:[],
                row:{}
            }
        },
        methods:{
            onButtonClick(item) {
                this.button = item
            }, 
            tableSelect(row) {
                this.row = row
            },
            conditionChange(conditions) {
                this.$refs.list.search()
            },
            close(item) {
                this.button = item
            }
        },
        components:{CommonExport, SearchPopUp,CommonList,CommonBtn}
    }
</script>
